#ifndef _LIBS_H_
#define _LIBS_H_
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdlib>
#include<queue>
#include<SpatialIndex.h>
//#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;
using namespace SpatialIndex;

const int DIMENSION=2;

class MyVisitor : public IVisitor 
{
 public:
  Region * target;
  size_t visitedNode;
  vector<int> nodeIndex;
 public:
 MyVisitor()
    {
      visitedNode=0;
      nodeIndex.clear();
    }
 void setTarget(Region *t);

 void visitData(const IData &d);
 
 void visitNode(const INode &n);
 
 bool validate(int id);
 
 void visitData(std::vector<const IData*>& v){}
};

struct node
{
  int operation,ID,dimension;
  double coordinate[DIMENSION+2];
};

struct cell
{
  int x,y;
};

void Pre1();
void Main1();
void Pre();
double Generate_Random_Noise();
void Matrix_Multiplication1(double ma[DIMENSION+2],double ans[DIMENSION+2]);
void Matrix_Multiplicaiont2(double ma1[DIMENSION+2],double
			    ma2[DIMENSION+2],double
			    ans[DIMENSION+2][DIMENSION+2]);
void Matrix_Multiplication3(double
			    ma1[DIMENSION+2][DIMENSION+2],double
			    ma2[DIMENSION+2][DIMENSION+2],double
			    ans[DIMENSION+2][DIMENSION+2]);
double Distance(double x,double y);
int Cal(double radius);
int Convert_Map_Index(double num);
bool Check_In_Circle(int now_x,int now_y,double raidus);
void Main();
void Binary_Search(double circle_radius);
double Cal_Result(double ma1[DIMENSION+2],double ma2[DIMENSION+2][DIMENSION+2]);
bool insert();

#endif
